package com.changgou.service.goods.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.changgou.goods.pojo.Spec;
import com.changgou.service.goods.dao.SpecMapper;
import com.changgou.service.goods.service.SpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Package: com.changgou.service.goods.service.impl
 * ClassName: SpecServiceImp
 * Description:
 *
 * @Author : 福森森
 * @Create : 2024/8/26 21:37
 */
@Service
public class SpecServiceImp extends ServiceImpl<SpecMapper, Spec> implements SpecService {
    @Autowired
    private SpecMapper specMapper;
    @Override
    public List<Map> findSpecListByCategoryName(String categoryName) {
        List<Map> specList = specMapper.findSpecListByCategoryName(categoryName);
        for(Map spec:specList){
            String[] options = ((String) spec.get("options")).split(",");
            //规格选项列表
            spec.put("options",options);
        }
        return specList;
    }
}
